﻿#include "simpletest.h"

SimpleTest::SimpleTest()
{

}

void SimpleTest::case1_testcase()
{
    MainWindow w1;
    memset(w1.map,0,sizeof(w1.map));
    w1.map[4][5] = 1;
    w1.map[5][4] = 1;
    w1.map[4][4] = 2;
    w1.map[5][5] = 2;
    w1.firstPos[2] = MainWindow::Pos(4,5);
    w1.secondPos[2] = MainWindow::Pos(5,4);
    QVERIFY(w1.checkRemovable(2,false) == false);
}

void SimpleTest::case2_testcase()
{
    MainWindow w1;
    memset(w1.map,0,sizeof(w1.map));
    for(int i = 4; i < 7; i++)
        for(int j = 4; j < 7; j++){
            w1.map[i][j] = 2;
        }
    w1.map[3][6] = 1;
    w1.map[6][3] = 1;
    w1.firstPos[2] = MainWindow::Pos(3,6);
    w1.secondPos[2] = MainWindow::Pos(6,3);
    QVERIFY(w1.checkRemovable(2,false) == true);
}

void SimpleTest::case3_testcase()
{
    MainWindow w1;
    memset(w1.map,0,sizeof(w1.map));
    for(int i = 4;i < 7;i++)
        for(int j = 4;j < 6;j++){
            w1.map[i][j] = 2;
        }
    w1.map[6][6] = 2;
    w1.map[5][6] = 1;
    w1.map[6][3] = 1;
    w1.firstPos[2]=MainWindow::Pos(6,3);
    w1.secondPos[2]=MainWindow::Pos(5,6);
    QVERIFY(w1.checkRemovable(2,false) == true);
}

void SimpleTest::case4_testcase()
{
    MainWindow w1;
    memset(w1.map,0,sizeof(w1.map));
    for(int i=4;i < 7;i++)
        for(int j=4;j < 6;j++){
            w1.map[i][j] = 2;
        }
    w1.map[4][3] = 2;
    w1.map[6][6] = 2;
    w1.map[5][6] = 1;
    w1.map[6][3] = 1;
    w1.firstPos[2]=MainWindow::Pos(6,3);
    w1.secondPos[2]=MainWindow::Pos(5,6);
    QVERIFY(w1.checkRemovable(2,false) == false);
}

void SimpleTest::case5_testcase()
{
    MainWindow w1;
    memset(w1.map,0,sizeof(w1.map));
    for(int i=4;i < 6;i++)
        for(int j=4;j < 8;j++){
            w1.map[i][j] = 2;
        }
    w1.map[4][5] = 1;
    w1.map[4][6] = 1;
    w1.firstPos[2]=MainWindow::Pos(4,5);
    w1.secondPos[2]=MainWindow::Pos(4,6);
    QVERIFY(w1.checkRemovable(2,false) == true);
}

void SimpleTest::case6_testcase()
{
    MainWindow w1;
    memset(w1.map,0,sizeof(w1.map));
    w1.firstPos[2]=MainWindow::Pos(4,4);
    w1.secondPos[2]=MainWindow::Pos(5,5);
    QVERIFY(w1.checkRemovable(2,false) == true);
}

void SimpleTest::case7_testcase()
{
    MainWindow w1;
    memset(w1.map,0,sizeof(w1.map));
    for(int i = 4; i  <  8; i++)
        w1.map[5][i] = 2;
    w1.map[4][4] = 2;
    w1.map[5][4] = 1;
    w1.map[4][7] = 1;
    w1.firstPos[2]=MainWindow::Pos(5,4);
    w1.secondPos[2]=MainWindow::Pos(4,7);
    QVERIFY(w1.checkRemovable(2,false) == false);
}

void SimpleTest::case8_testcase()
{
    MainWindow w1;
    memset(w1.map,0,sizeof(w1.map));
    for(int i=4;i < 8;i++)
        for(int j=4;j < 7;j++){
            w1.map[i][j] = 2;
        }
    w1.map[6][4] = 0;
    w1.map[6][5] = 0;
    w1.map[6][6] = 0;
    w1.map[5][4] = 1;
    w1.map[7][6] = 1;
    w1.firstPos[2]=MainWindow::Pos(5,4);
    w1.secondPos[2]=MainWindow::Pos(7,6);
    QVERIFY(w1.checkRemovable(2,false) == true);
}

void SimpleTest::case9_testcase()
{
    MainWindow w1;
    memset(w1.map,0,sizeof(w1.map));
    for(int i=4;i < 6;i++)
        for(int j=4;j < 7;j++){
            w1.map[i][j] = 2;
        }
    w1.map[4][5] = 1;
    w1.map[6][5] = 1;
    w1.firstPos[2]=MainWindow::Pos(4,5);
    w1.secondPos[2]=MainWindow::Pos(6,5);
    QVERIFY(w1.checkRemovable(2,false) == false);
}
//QTEST_MAIN(SimpleTest)
